<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx">
          <template #originalNo>
            <el-input v-model="ctx.otherFilter.originalNo" placeholder="请输入源单"></el-input>
          </template>
          <template #warehouseName>
            <el-select v-model="ctx.filter.warehouseId">
              <el-option v-for="item in warehouseOptions" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['wms-order:import:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['wms-order:import:list']" :loading="ctx.exportLoading"
              icon="Download" @click="ctx.export()">
              导出
            </el-button>
            <!-- <el-button type="primary" v-hasPermit="['wms-order:import:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button> -->
          </span>
        </div>
      </template>
      <template #category="scope">
        {{ ctx.other.getCategoryName(scope.row.category) }}
      </template>
      <template #status="scope">
        {{ ctx.other.getStatusName(scope.row.status) }}
      </template>
      <template #createOn="scope">
        {{ ctx.other.formatDt(scope.row.createOn) }}
      </template>
      <template #operation="scope">
        <el-button type="primary" v-hasPermit="['wms-order:import:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          明细
        </el-button>
        <el-button v-hasPermit="['wms-order:import:del']" type="danger" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog v-model="ctx.editVisible" width="90%" append-to-body :close-on-click-modal="false"
          @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-row>
              <el-col :span="8">
                <el-row>
                  检验人员：<div class="bold">{{ ctx.editData.inspector || '-' }}</div>
                </el-row>
              </el-col>
              <el-col :span="8">
                <el-row>
                  收货人员：<div class="bold">{{ ctx.editData.consignee || '-' }}</div>
                </el-row>
              </el-col>
              <el-col :span="8">
                <el-row>
                  审核人员：<div class="bold">{{ ctx.editData.reviewer || '-' }}</div>
                </el-row>
              </el-col>
            </el-row>
            <el-divider content-position="center">物料明细</el-divider>
            <el-table :data="ctx.editData.orderGoodsList" style="width: 100%;margin-top: 10px;">
              <el-table-column prop="skuName" label="物料名称" width="600"/>
              <el-table-column prop="barCode" label="物料编码" width="150" />
              <el-table-column prop="serialNumber" label="出厂编号" width="150" />
              <el-table-column prop="specification" label="规格型号">
                <template #default="scope">
                  {{ scope.row.specification || '-' }}
                </template>
              </el-table-column>
              <el-table-column prop="locationCode" label="库位编码" width="120">
                <template #default="scope">
                  {{ scope.row.locationCode || '-' }}
                </template>
              </el-table-column>
              <el-table-column prop="number" label="数量" width="100">
                <template #default="scope">
                  {{ scope.row.number || '-' }}
                </template>
              </el-table-column>
              <el-table-column prop="unit" label="单位" width="55">
                <template #default="scope">
                  {{ scope.row.unit || '-' }}
                </template>
              </el-table-column>
            </el-table>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button v-if="ctx.editData.status === '11'" type="success" @click="ctx.other.pass()">审核通过</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./import" />

<style lang="scss" scoped>
.bold {
  font-weight: 600;
}
</style>
